/*    */ package cc.s2m.web.s2mBlog.controller;
/*    */ 
/*    */ import cc.s2m.util.IpUtil;
/*    */ import cc.s2m.web.s2mBlog.controller.base.BaseController;
/*    */ import cc.s2m.web.s2mBlog.pojo.Articles;
/*    */ import cc.s2m.web.s2mBlog.pojo.Comment;
/*    */ import cc.s2m.web.s2mBlog.service.IArticles;
/*    */ import cc.s2m.web.s2mBlog.service.IComment;
/*    */ import com.google.common.base.Strings;
/*    */ import java.util.Date;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.bind.annotation.ResponseBody;
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"/comment"})
/*    */ public class CommentController extends BaseController
/*    */ {
/*    */ 
/*    */   @Autowired
/*    */   private IArticles articlesService;
/*    */ 
/*    */   @Autowired
/*    */   private IComment commentService;
/*    */ 
/*    */   @RequestMapping(value={"/save"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String detail(HttpServletRequest request, Comment bean)
/*    */   {
/* 33 */     if (bean == null) {
/* 34 */       return "empty";
/*    */     }
/* 36 */     if (bean.getAid() == null) {
/* 37 */       return "empty";
/*    */     }
/* 39 */     if (Strings.isNullOrEmpty(bean.getName())) {
/* 40 */       return "empty";
/*    */     }
/* 42 */     if (Strings.isNullOrEmpty(bean.getMsg())) {
/* 43 */       return "empty";
/*    */     }
/* 45 */     Articles article = (Articles)this.articlesService.selectByPrimaryKey(bean.getAid());
/* 46 */     if (article == null) {
/* 47 */       return "noArticle";
/*    */     }
/* 49 */     String ip = IpUtil.getIp(request);
/*    */ 
/* 51 */     Comment condition = new Comment();
/* 52 */     condition.setIp(ip);
/* 53 */     Comment lastThisipComment = (Comment)this.commentService.getByCondition(condition);
/* 54 */     if (lastThisipComment != null) {
/* 55 */       long rex = new Date().getTime() - lastThisipComment.getDateAdd().getTime();
/* 56 */       rex = rex / 1000L / 60L;
/* 57 */       if (rex < 1L) {
/* 58 */         return "tooFreq";
/*    */       }
/*    */     }
/*    */ 
/* 62 */     this.articlesService.addCommentNumber(article.getId().intValue());
/*    */ 
/* 64 */     bean.setIp(ip);
/* 65 */     bean.setDateAdd(new Date());
/* 66 */     this.commentService.insertSelective(bean);
/* 67 */     return "success";
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.controller.CommentController
 * JD-Core Version:    0.6.1
 */